//
// Created on 2024/3/12.
//
// Node APIs are not fully supported. To solve the compilation error of the interface cannot be found,
// please include "napi/native_api.h".

#include "TextInfoMap.h"
#include <unistd.h>

TextInfoMap *TextInfoMap::globalInfoMap = nullptr;

TextInfoMap::TextInfoMap() {}

TextInfoMap::~TextInfoMap() {}


TextInputInfo *TextInfoMap::getTextInputInfo(int32_t viewTag) { return textInputMap[viewTag]; }

void TextInfoMap::addTextInputInfo(int32_t viewTag, TextInputInfo *textInputInfo) {
    textInputMap[viewTag] = textInputInfo;
}

void TextInfoMap::deleteTextInputByTag(int32_t viewTag){
    if(textInputMap[viewTag]){
       delete textInputMap[viewTag];
    }
    textInputMap.erase(viewTag);
}

TextAreaInfo *TextInfoMap::getTextAreaInfo(int32_t viewTag) { return textAreaMap[viewTag]; }

void TextInfoMap::addTextAreaInfo(int32_t viewTag, TextAreaInfo *textAreaInfo) {
    textAreaMap[viewTag] = textAreaInfo;
}

void TextInfoMap::deleteTextAreaByTag(int32_t viewTag) {
    if (textAreaMap[viewTag]) {
       delete textAreaMap[viewTag];
    }
    textAreaMap.erase(viewTag);
}